package com.dayatang.hrm.compensation.domain;

import javax.persistence.Embeddable;
import javax.persistence.Embedded;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.dayatang.commons.domain.Value;
import com.dayatang.commons.domain.ValueObject;
import com.dayatang.hrm.compensation.policy.RoundingModePolicy;
import com.dayatang.hrm.compensation.vo.NumberScale;

/**
 * 薪资项目档案
 * 
 * @author chencao
 * 
 */
// @BatchSize(size = 10)
@Embeddable
public class SalaryItemArchive implements ValueObject,
		Comparable<SalaryItemArchive> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8952425306072450991L;

	// 薪资项目
	@ManyToOne
	@JoinColumn(name = "salary_item_id")
	private SalaryItem salaryItem;

	// 值
	@Embedded
	private Value value;

	// // 薪资项目档案排序号
	// @Column(name = "order_seq")
	// private Integer orderSeq;
	// // 进位策略
	// @ManyToOne
	// @JoinColumn(name = "rounding_mode_policy_id")
	// private RoundingModePolicy roundingModePolicy;
	// // 计算精度
	// @Embedded
	// @AttributeOverride(name = "digitAmount", column = @Column(name =
	// "calculate_scale"))
	// private NumberScale calculateScale;
	// // 显示精度
	// @Embedded
	// @AttributeOverride(name = "digitAmount", column = @Column(name =
	// "display_scale"))
	// private NumberScale displayScale;

	public SalaryItemArchive() {
	}

	public SalaryItemArchive(SalaryItem salaryItem) {
		this.salaryItem = salaryItem;
	}

	public Value getValue() {
		return value;
	}

	public SalaryItem getSalaryItem() {
		return salaryItem;
	}

	public void setSalaryItem(SalaryItem salaryItem) {
		this.salaryItem = salaryItem;
	}

	public void setValue(Value value) {
		this.value = value;
	}

	public Integer getOrderSeq() {
		// TODO
		return null;
	}

	public RoundingModePolicy getRoundingModePolicy() {
		// TODO
		return null;
	}

	public NumberScale getCalculateScale() {
		// TODO
		return null;
	}

	public NumberScale getDisplayScale() {
		// TODO
		return null;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof SalaryItemArchive == false) {
			return false;
		}
		if (this == obj) {
			return true;
		}
		SalaryItemArchive rhs = (SalaryItemArchive) obj;
		return new EqualsBuilder().append(getSalaryItem(), rhs.getSalaryItem())
				.isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder(17, 37).append(getSalaryItem()).toHashCode();
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this,
				ToStringStyle.SHORT_PREFIX_STYLE);
	}

	@Override
	public int compareTo(SalaryItemArchive arg0) {
		return this.getSalaryItem().getOrderSeq().compareTo(
				getSalaryItem().getOrderSeq());
	}

}
